﻿/// <reference path="JQUERY/jquery-1.10.2.min.js" />
/// <reference path="JQUERY/bootstrap.min.js" />
var admin_left, admin_list, admin_list_search, search_closer, admin_list_search_Form, admin_right;
var frame_right;
var throttleTimeout_index;
var ckfinderImgGetter_Dom, ckfinderImgGetter_Input;
var isMobile = false, enableDrop = true;
var finder, ckFinder_selectAction = true, ckFinder_showSelectPic = true;
var popover, frame_popover;
var BlackBoard, PicShow_PicBox, PicShow_Img, ShowPre, ShowNext, PicShow_closer, PicShow_Info;
function menulink(title_, href_) {
    var _this = this;
    this.title = title_;
    this.href = href_;
}

$(function () {
    if (screen.width < 768) isMobile = true;
    $("body").addClass(isMobile ? "M" : "T");

    //document.ontouchmove = function (e) {
    //    var target = e.target;
    //    while (target) {
    //        var maybe_scrollBox4ios = $(target).closest(".scrollBox4ios");
    //        if (maybe_scrollBox4ios.length > 0 && maybe_scrollBox4ios.height() < maybe_scrollBox4ios[0].scrollHeight) return;
    //        target = target.parentNode;
    //    }

    //    e.preventDefault();
    //}
})
//登陆框
function Dom_Login() {
    $(".NewSMS_item:visible").remove();
    //$(".btn-submit").fastClick(function () {
    //    if ($(this).hasClass("disabled")) return false;
    //    else $(this).addClass("disabled");
    //})
}
//管理页面
function Dom_Default() {

    admin_left = $("#admin_left");
    admin_list = $("#admin_list");
    admin_list_search = $("#admin_list_search");
    search_closer = $("#search_closer");
    admin_list_search_Form = $("#admin_list_search_Form");
    admin_right = $("#admin_right");

    frame_right = $("#frame_right");

    popover = $("#popover");
    frame_popover = $("#frame_popover");

    BlackBoard = $("#BlackBoard");
    PicShow_PicBox = $("#PicShow_PicBox");
    PicShow_Img = PicShow_PicBox.find("img");
    ShowPre = $("#ShowPre");
    ShowNext = $("#ShowNext");
    PicShow_closer = $("#PicShow_closer");
    PicShow_Info = $("#PicShow_Info");

    //var temp = $("#template_div div:first").clone();
    //var tempo = Tempo.prepare(temp);
    //admin_left.html("");
    //tempo.into(admin_left).render(data_menu);

    try {
        finder = new CKFinder();
        finder.basePath = '/ckfinder/';
        // The default height is 400.
        finder.height = "100%";
        finder.selectActionFunction = selectActionFunction;
        finder.callback = function () {
            // setTimeout("CkFinder_load()", 5000);

            CkFinder_load();
        }
    }
    catch (e) { }
    Event_Default();
}
function Event_Default() {

    //try {

    //    document.body.addEventListener("touchmove", function (event) { event.preventDefault(); return false; });
    //} catch (er) { }

    popover.find(".fa-times").fastClick(function () { popover_close(); })
    //$(".List_bt_goBack").fastClick(function () {
    //    frameList_Goback();
    //})

    BlackBoard.fastClick(function () { PicShow_close(); });
    PicShow_closer.fastClick(function () { PicShow_close(); });
    ShowPre.fastClick(function () { ShowPreNext(-1); })
    ShowNext.fastClick(function () { ShowPreNext(1); })
    $(document).keyup(function (event) {
        if (event.keyCode == '37') { ShowPreNext(-1); }
        if (event.keyCode == '39') { ShowPreNext(1); }
    });


    if ($(".left_menu_title_kaiguan").length > 0) $(".left_menu_title_kaiguan").hover(
            function () {
                $(this).siblings(".left_menu_title_con").addClass("left_menu_title_con_border");
            },
            function () {
                $(this).siblings(".left_menu_title_con").removeClass("left_menu_title_con_border");
            })
            .fastClick(function () {
                var me = $(this), me_menu = me.parents(".left_menu");
                //var meclass;
                if (me.hasClass("left_menu_title_kaiguan_open")) {
                    me.removeClass("left_menu_title_kaiguan_open");
                    //meclass = me.attr("class");
                    //me.attr("class", meclass.replace("_open_18", "_18").replace("_open_24", "_24"));
                    $("ul", me_menu).stop().animate({ opacity: 0 }).slideUp("fast", function () { resizeDOM_index(); });
                
                } else {
                   // $(".left_menu_title_kaiguan_open").click();
                    me.addClass("left_menu_title_kaiguan_open");
                    //meclass = me.attr("class");
                    //me.attr("class", meclass.replace("_18", "_open_18").replace("_24", "_open_24"));
                    $("ul", me_menu).stop().animate({ opacity: 1 }).slideDown("fast", function () { resizeDOM_index(); });
                }
                return false;
            });
    admin_left.find("[href-right]").each(function () {
        href_right_click(this);
    })
    if ($("[href-list] .left_menu_title_con").length > 0) {
        $("[href-list] .left_menu_title_con")
        .fastClick(function () {
            var thisMenu = $(this).parents(".left_menu");
            var nowIsOpenMenu = $(".left_menu_title_kaiguan_open").parents(".left_menu");
            if (nowIsOpenMenu && thisMenu.find(".left_menu_title").attr("href-list") != nowIsOpenMenu.find(".left_menu_title").attr("href-list")) {
                nowIsOpenMenu.find(".left_menu_title_kaiguan").fastClick();
            }

            $(".left_menu_ison").removeClass("left_menu_ison");
            var me_title = $(this).parents("[href-list]");
            me_title.addClass("left_menu_ison");
            close_adminRight();
            parent.popover_close();
            if (me_title.is("[href-list]") && me_title.attr("href-list") != "") {

                var _AbsoluteUrl = getAbsoluteUrl(me_title.attr("href-list"));
                showMenu(_AbsoluteUrl.toLowerCase(), function () {
                    open_frameList(me_title.attr("href-list"), false, me_title.attr("title"));

                });
            }
            if (me_title.is("[href-right]") && me_title.attr("href-right") != "") open_frameList(me_title.attr("href-list"), false, me_title.attr("title"));
            if (me_title.is("[myhref]") && me_title.attr("myhref") != "")
                parent.open_frameRight(me_title.attr("[myhref]"), $(this).html());
            return false;
        });
    }
    admin_left.find(".nomenuson [href-list],ul [href-list]").each(function () {
        $(this).attr("data-AbsoluteUrl", getAbsoluteUrl($(this).attr("href-list")).toLowerCase());
    });
    //frame_right载入动作
    frame_right.load(function () {
        if (!isMobile) {
            frame_right.width(0).height(0);
            if (frame_right.attr("src") != "") {
                //var minWidth = $(this).contents().width() * 1 + 15;
                var minWidth = $(this).contents().width();
                //alert(minWidth);
                if (minWidth == 0) minWidth = 300;
                else
                    minWidth = accAdd(minWidth, 15);
                //alert(minWidth);
                //var minWidth = frame_right.contents().find("body").height() * 1 + 15;
                //if ($(this).contents().outerHeight(true) > admin_right.height()) minWidth += scrollSize;
                frame_right.width(minWidth).attr("minWidth", minWidth);

            }
        }
        if (frame_right.attr("src") != "") resizeDOM_adminRight();

    })
    //关闭right
    if ($("#close_right").length > 0) $("#close_right").fastClick(function () { close_adminRight(); return false; });


    //搜索
    search_closer.fastClick(function () {

        close_search();
    });

    $(window).resize(function () {
        if (!throttleTimeout_index) {
            throttleTimeout_index = setTimeout(
        function () {
            resizeDOM_index();
            throttleTimeout_index = null;
        },
        500
    );
        }
    });

    $("#ckFinder_close").fastClick(function () {
        closeCkFinder();
    })
    //Mobile

    $("#admin_bottom_M .fa-bars").fastClick(function () {
        if (admin_list.offset().left != 0) Show_admin_list_M();
        else Show_admin_left_M();
    })
    $("#admin_bottom_M .fa-home").fastClick(function () {
        if (admin_list.offset().left != 0) Show_admin_list_M();
        else Show_me_info_M();
    })
    $("#admin_bottom_M").fastClick(function () {
        if (admin_list.offset().left != 0) Show_admin_list_M();
    })

    Page_Default();
}
function Page_Default() {

    admin_left.find(".left_menu_title_con:first").click();
    // $("[name=frame_list]:last").attr("src", admin_left.find("[href-list]:first").attr("href-list"));;
}
//刷新Timer1
function Timer1_Update() { $("[id$=bt_Timer1]").click(); }
function logOut() { $("[id$=bt_logOut]").click(); }
function touchmove(e) {
    return false;
}

//Mobile
//显示admin_left
function Show_admin_left_M() { admin_list.animate({ left: admin_left.width(), right: -admin_left.width() }, "fast", function () { admin_left.addClass("isshow") }); }
//显示me_info
function Show_me_info_M() {
    admin_list.animate({ left: -$("#me_info").width(), right: $("#me_info").width() }, "fast", function () { });
}
//隐藏 admin_left  和 me_info
function Show_admin_list_M() {
    admin_left.removeClass("isshow");
    admin_list.animate({ left: 0, right: 0 }, "fast", function () { });
}
function left_menu_kai() {

}
function left_menu_guan() {

}

//构造顶部多个控件
function Build_Top_Control_Box(controls_) {

    //var cloneControls = controls_.clone();
    //var List_ing = $(".ListBox.ing");
    //var _Top_Control_Box = List_ing.find(".Top_Control_Box");
    ////alert(cloneControls.outerHTML());
    //_Top_Control_Box.html(cloneControls.outerHTML());
    //// _Top_Control_Box.html("").append("<BUTTON class=\"btn btn-danget\" href-right=\"Form.aspx\" quanxian=\"add\" datitle=\"tianjaneirong\">ADD</BUTTON>");
    ////alert(_Top_Control_Box.outerHTML());
    //bindEvent_href(_Top_Control_Box);


   
    var List_ing = $(".ListBox.ing");
    var _Top_Control_Box = List_ing.find(".Top_Control_Box");
    _Top_Control_Box.html("").append(controls_.html());
    bindEvent_href(_Top_Control_Box);
}
//显示搜索按钮
function showSearchOpener() {
    var List_ing = $(".ListBox.ing");
    List_ing.find(".search_opener").show();
    List_ing.find(".ListBox_Top").addClass("hasSearch");
}
//隐藏搜索按钮
function hideSearchOpener() {
    var List_ing = $(".ListBox.ing");
    List_ing.find(".search_opener").hide();
    List_ing.find(".ListBox_Top").removeClass("hasSearch");
}
//打开搜索
function open_search() {
    close_adminRight();
    popover_close();
    var List_ing = $(".ListBox.ing");
    List_ing.find(".search_opener").animate({ right: 0, opacity: 0 }, function () { $(this).hide(); });
    var table_search = List_ing.find("iframe").contents().find("#div_search_con");
    //if ($("#div_search_con").length == 0 || $("#div_search_con").html() != table_search.html()) {
    admin_list_search_Form.html("");
    admin_list_search_Form.append(table_search.clone());
    //}

    if (admin_list_search.is(":hidden")) {
        admin_list_search.show().css({ opacity: 0, width: 0 });
        admin_list_search.width(admin_list_search_Form.find("#div_search_con").width());
        var left2 = admin_left.width() * 1 + $(".ListBox.ing iframe").width() * 1;
        admin_list_search.stop().css({ left: left2 - 26 });
    }
    admin_list_search.stop().animate({ left: left2, opacity: 1 });
    //$("select").not("[class*=select2]").not("[data-noselect2]").select2();
}
//关闭搜索
function close_search() {
    var List_ing = $(".ListBox.ing");
    //if ($("#div_search_con .control-group").length > 0 && $("#div_search_con").html() != "")
    //    $("#search_opener").show().css({ opacity: 0 }).animate({ right: 10, opacity: 1 });

    var left2 = admin_left.width() * 1 + List_ing.find(" iframe").width() * 1;
    admin_list_search.stop().animate({ left: left2 - 26, opacity: 0 }, function () { admin_list_search.hide(); });
    //try { $(".ListBox.ing iframe")[0].contentWindow.close_search(); }
    //catch (err) { }
    List_ing.find(".search_opener").show().css({ opacity: 0 }).animate({ right: 10, opacity: 1 });
}
//开始搜索
function search_submit() {
    var List_ing = $(".ListBox.ing");
    List_ing.find("iframe")[0].contentWindow.searchStart($("#div_search_con"));
}
function search_default() {
    var searchFrom = $("#admin_list_search_form");
    searchFrom.find('input:checkbox').removeAttr('checked');
    searchFrom[0].reset();
    search_submit();
}

function toplistshowsearch() {
   
    var List_ing = $(".ListBox.ing");
    var _Top_Control_Box = $(List_ing[0]).find(".Top_Control_Box")[0];
    var searchcontet = $(_Top_Control_Box).find("#top_search_content").val();
    $(List_ing.find("iframe")[0]).attr("src", "/store/goods/list.aspx?istopsearch=1&search_text_namenumber=" + searchcontet);

    
    Build_Top_Control_Box($("#Top_Control_Box"));
    //showSearch = true;
    //var List_ing = $(".ListBox.ing");
    //var searchbtn = $(List_ing.find("iframe")[0].document).find("[data-id=bt_search]")
    
}

function toplistsearch(type) {

    var List_ing = $(".ListBox.ing");
    var _Top_Control_Box = $(List_ing[0]).find(".Top_Control_Box")[0];
    var searchcontet = $(_Top_Control_Box).find("#top_search_content").val();
    var url = "/sys/goods/list.aspx?istopsearch=1&search_text_fuzzy=" + searchcontet;
    if (type) url = "/sys/Group_Buy/Good_List.aspx?istopsearch=1&search_text_fuzzy=" + searchcontet;

    $(List_ing.find("iframe")[0]).attr("src", url);


    Build_Top_Control_Box($("#Top_Control_Box"));
    //showSearch = true;
    //var List_ing = $(".ListBox.ing");
    //var searchbtn = $(List_ing.find("iframe")[0].document).find("[data-id=bt_search]")

}

function EnterPress(el,type,e)
{
    var e = e || window.event;
    if (e.keyCode == 13) {
        if (type == 1) {
            toplistshowsearch();
        } else if (type == 2) {
            toplistsearch();
        } else {
            toplistsearch("gb");
        }
    }
}



//刷新updatepanel列表数据
function frame_list_page_build() {
    frame_list_page_build("");
}
function frame_list_page_build(fenghuolun_TrDatakey) {
    $(".ListBox.ing iframe")[0].contentWindow.page_build(fenghuolun_TrDatakey);
}
//frameList载入网页
function open_frameList(href_, newFrame_, title_) {
    var List_ing = $(".ListBox.ing");
    if (List_ing.find(".ListBox_Top").hasClass("hasSearch")) close_search();




    //List_ing.find("iframe").removeClass("ing");
    if (newFrame_) {
        var List_New = List_ing.clone();
        //初始化顶部
        List_New.find(".Top_Control_Box").html("");
        List_New.find(".ListBox_Top").removeClass("hasSearch").removeClass("hasGoBack");
        List_New.find(".search_opener").hide();


        List_ing.removeClass("ing")
        List_New.find("iframe").attr("src", "").css({ opacity: 0 }).show();;

        List_New.find(".List_bt_goBack").fastClick(function () {
            frameList_Goback();
        })

        List_New.find(".List_bt_goBack").show();
        List_New.find(".ListBox_Top").addClass("hasGoBack");
        List_New.find(".ListCount").hide();
        if (title_)
        {
            List_New.find(".ListTitle").html(title_);
            //var searchHtml = '<div><input  type="text" id="searchContent"/><button class="btn btn-danger" >查找</button></div>';
            //List_New.find(".ListTitle").after(searchHtml);
        }
        List_New.attr("target", "_blank").css({ left: admin_list.width() }).appendTo(admin_list).animate({ left: 0 }, function () {
            List_New.find("iframe").attr("src", href_);
            fenghuolun_open_(List_New.find("iframe"), 0, true);
        });

        //var frame_list_last = $("[name=frame_list][target]:last");
        //var frame_list_new = $("[name=frame_list][target]:last").clone();
        //frame_list_new.attr("src", "").attr("target", "_blank").css({ marginLeft: admin_list.width() }).appendTo(admin_list).animate({ marginLeft: 0 }, function () {
        //    frame_list_new.attr("src", href_);
        //    fenghuolun_open_(frame_list_new, 1, true, "f8f8f8");
        //});
        List_ing.animate({ opacity: 0, left: -List_ing.width() * 3 / 10 }, function () { List_ing.hide(); });
        //frame_list_last.animate({ opacity: 0, marginLeft: -frame_list_last.width() }, function () { frame_list_last.hide(); });
    } else {
        //初始化顶部
        List_ing.find(".Top_Control_Box").html("");
        List_ing.find(".ListBox_Top").removeClass("hasSearch").removeClass("hasGoBack");
        List_ing.find(".search_opener").hide();

        if (admin_list.is(":visible")) fenghuolun_open_(iframe_ing, 0, true);
        List_ing.siblings(".ListBox").remove();
        var iframe_ing = List_ing.find("iframe");
        if (!!window.ActiveXObject) admin_list.fadeIn();
        iframe_ing.attr("src", href_);
        iframe_ing.css({ opacity: 0 }).show();
        iframe_ing.attr("target", "self");
        List_ing.find(".ListTitle").html(title_);
        List_ing.find(".List_bt_goBack,.ListCount").hide();
        fenghuolun_open_(List_ing.find("iframe"), 0, true);
    }
}
//frameList载入网页ok
function frame_list_ok(showSearch, listCount_) {
    //return;
    if (!isMobile) {
        var List_ing = $(".ListBox.ing");
        var frame_ing = List_ing.find("iframe");
        var firstLoad = false;
        if (admin_list.is(":hidden")) firstLoad = true;
        admin_list.show();
        frame_ing.width(0);
        var frameWidth = frame_ing.contents().find("body").outerWidth(true) * 1 + 0;
        if (frame_ing.contents().outerHeight(true) > admin_list.height()) {
            frameWidth += scrollSize;
            List_ing.find(".ListBox_Top,.ListBox_Top_bg").css({ right: scrollSize });
        } else List_ing.find(".ListBox_Top,.ListBox_Top_bg").css({ right: 0 });
        frame_ing.width(frameWidth);
        frame_ing[0].contentWindow.title = List_ing.find("h3").html();
        if (firstLoad) {
            admin_list.hide();
            $("#PublicTimerBox").fadeIn();
        }
        if (frame_ing.is("[target=_blank]")) {
            List_ing.find(".List_bt_goBack").show();
            frame_ing[0].contentWindow.showGoback();
        }
        admin_list.animate({ left: admin_left.width() }, "fast", function () {
            if (showSearch) open_search();
            //if (showSearch) frame_ing[0].contentWindow.open_search();
            //else close_search();
            //else admin_list_search.animate({ left: admin_left.width() * 1 + admin_list.width() * 1 }, "fast");
        });
        //
        if (listCount_) {
            //var _Element_listCount = List_ing.find(".ListCount");
            //_Element_listCount.find("b").html(listCount_);
            ////if (listCount_ * 1 == 0) _Element_listCount.hide();
            //_Element_listCount.show();
        } else resizeDOM_index();
    }
    //resizeDOM_index();
}
function frameList_Goback() {
    var List_ing = $(".ListBox.ing").addClass("del");
    List_ing.find("iframe").addClass("del");
    //
    var ListPre = List_ing.prev(".ListBox").addClass("ing");
    var framePre = ListPre.find("iframe").addClass("ing");
    var framePreW = framePre.width();

    $(".ListBox.del").removeClass("ing").find("iframe").removeClass("ing");

    ListPre.show().css({ opacity: 1 }).animate({ left: 0 }, function () {
        frame_list_page_build("");
        showMenu(framePre[0].contentDocument.location.pathname.toLowerCase());
    });
    $(".ListBox.del").show().animate({ left: framePreW }, function () {
        $(".ListBox.del").remove();
    });
    admin_list.animate({ width: framePreW });
    close_search();
}


//在admin_right中打开网页
function open_frameRight(url_, title_) {
    $("#title_right").hide().html(title_);
    $("#close_right").hide();
    if (isMobile) {
        admin_right.show();
        fenghuolun_open(admin_right);
        // frame_right.height(admin_right.height() - $("#title_right").outerHeight(true));
        //frame_right.height(admin_right.height() );
        //frame_right.show();
    }
    frame_right.attr("src", url_);
    //
    if (!isMobile) {
        if (frame_right.is(":hidden")) resizeDOM_adminRight_(true, false);
        else fenghuolun_open(admin_right);
    }
}
function frameRight_ok() {

}
//关闭admin_right
function close_adminRight() {
    frame_right.hide().removeAttr("minWidth").attr("src", "");
    admin_right.fadeOut("fast", function () {
        $("#title_right").html("");
    });
    closeCkFinder();
    popover_close();
    fenghuolun_close(admin_right);
}






//调整admin_list 尺寸
function resizeDOM_index() {
    var List_ing = $(".ListBox.ing"), ListIframe_ing = List_ing.find("iframe");
    if (!isMobile) {
        admin_left.stop().animate({ opacity: 1 }, function () {
            admin_list.css({ left: admin_left.width() });
            //admin_list_search.css({ left: admin_left.width() * 1 + admin_list.width() * 1 });
            // admin_left.width(admin_left.outerWidth());

            if (admin_list.is(":hidden")) {
                admin_list.width($("[name=frame_list][target]:last").width()).fadeIn("fast", function () {
                    $("[name=frame_list][target]:last").add(admin_left).animate({ "opacity": 1 });
                    $("#loading").hide();
                    if (admin_right.is(":visible")) resizeDOM_adminRight();
                })

                admin_list_search.css({ left: admin_left.width() * 1 + $("[name=frame_list][target]:last").width() * 1 });
            }
            else {
                var List_ing_Width = ListIframe_ing.contents().find("body").outerWidth(true) * 1 + 0;
                if (ListIframe_ing.contents().outerHeight(true) > admin_list.height()) {
                    List_ing_Width += scrollSize;
                    List_ing.find(".ListBox_Top,.ListBox_Top_bg").css({ right: scrollSize });
                } else List_ing.find(".ListBox_Top,.ListBox_Top_bg").css({ right: 0 });
                ListIframe_ing.width(List_ing_Width);


                admin_list.animate({ width: $("[name=frame_list][target]:last").width() }, "fast", function () {
                    $("[name=frame_list][target]:last").add(admin_left).animate({ "opacity": 1 });
                    if (admin_right.is(":visible")) resizeDOM_adminRight();
                })
                admin_list_search.animate({ left: admin_left.width() * 1 + $("[name=frame_list][target]:last").width() * 1 }, "fast");
            }
            if (admin_right.is(":visible")) resizeDOM_adminRight();
        })
    }
    else {
        admin_list.show();
        $("[name=frame_list][target]:last").add(admin_left).css({ opacity: 1 });
        $("#loading").hide();
        ListIframe_ing.show();
    }
    $("#loading").hide();
    fenghuolun_close($("[name=frame_list][target]:last"));
    setTimeout(function () {
        var logo1Left = ($(window).width() - admin_left.width() - admin_list.width()) / 2;
        if (!isMobile) logo1Left = accAdd(logo1Left, (admin_left.width() * 1 + admin_list.width() * 1));
        $("#logo1").fadeIn().css({ left: logo1Left });
    }, 1000);
    //}
    //try{
    //    //frame_list[0].contentWindow.make_pageSize();
    //}
    //catch(e){}
    resize_popover();
}
//调整admin_right 尺寸
function resizeDOM_adminRight() {
    if (frame_right.is(":visible")) resizeDOM_adminRight_(false, true);//调整窗口尺寸时调用
    else resizeDOM_adminRight_(false, false);//iframe载入完毕
    //frame_right.height(admin_right.height() - $("#title_right").outerHeight(true));
    //frame_right.height(100);
    var frame_rightH = frame_right.contents().outerHeight(true);
    if (frame_rightH <= admin_right.height() - 50) frame_rightH = "100%";
    frame_right.height(frame_rightH).show();
    //if (frame_right.attr("src") != "") frame_right.fadeIn("fast");

}
//调整admin_right 尺寸（是否 iframe载入之前，是否iframe载入完毕 且 是修改窗口尺寸时调用的）
function resizeDOM_adminRight_(beforeFrameLoad, afterFrameLoad) {
    if (!isMobile) {
        //窗口宽度
        var winWidth = $(window).width();
        //右边空白区域的offset.Left
        var RightBlank_offset_Left = admin_list.offset().left * 1 + admin_list.outerWidth(true) * 1;
        //右边空白区域宽度
        var RightBlank_width = winWidth - RightBlank_offset_Left;
        //1.求frame_right宽度,admin_right宽度
        var frame_right_width2 = 0, admin_right_width2 = 0;
        if (beforeFrameLoad) {
            frame_right_width2 = RightBlank_width;//首次载入，默认占满右边空白
            admin_right_width2 = frame_right_width2;
        }
        else {
            //滚动条要占用的宽度
            var needScrollWidth = frame_right.contents().outerHeight(true) > admin_right.height() ? scrollSize : 0;
            //扣去滚动条，右边空白区域剩余宽度
            RightBlank_width -= needScrollWidth;
            //
            if (accAdd(frame_right.attr("minWidth"), needScrollWidth) < RightBlank_width) {
                frame_right_width2 = "100%";//实际宽度小，则让admin_right来控制
                admin_right_width2 = accAdd(RightBlank_width, needScrollWidth);
            }
            else {
                frame_right_width2 = frame_right.attr("minWidth");
                admin_right_width2 = accAdd(frame_right_width2, needScrollWidth);
            }
        }
        frame_right.width(frame_right_width2);

        if (beforeFrameLoad || afterFrameLoad) {
            admin_right.width(admin_right_width2).show();
            if (beforeFrameLoad) fenghuolun_open(admin_right);
            else {
                fenghuolun_close(admin_right);
                $("#title_right,#close_right").show();
            }
            // alert(frame_right.is(":visible"));
        } else {
            admin_right.animate({ width: admin_right_width2 }, "fast", function () {
                if (frame_right.attr("src") != "") frame_right.show();
                fenghuolun_close(admin_right);
                $("#title_right,#close_right").show();
            });
        }
        $("#ckFinderBox").width(admin_right.offset().left);
    }
    else {
        fenghuolun_close(admin_right);
        $("#title_right,#close_right").show();
    }
    $("#ckFinderBox").find("iframe").height($("#ckFinderBox").height() - $("#ckFinder_title").height());

}

//可以自动关闭的提示
function Alert_float(msgtitle, isSuccess) {
    var msgcss = "correct";
    if (!isSuccess) msgcss = "error";
    Alert_float_(msgtitle, msgcss);
}
function Alert_float_(msgtitle, msgcss) {
    top.$("#Alert_float").remove();
    var newAlert = $("<div id=\"Alert_float\" class=\"" + msgcss + "\">" + msgtitle + "</div>").appendTo(top.$("body"));
    newAlert.css("marginLeft", -newAlert.width() / 2).fadeIn();

    //3秒后清除提示
    setTimeout(function () {
        newAlert.fadeOut(500);
        //如果动画结束则删除节点
        if (!newAlert.is(":animated")) {
            newAlert.remove();
        }
    }, 3000);
}
function showMenu_(pathName) {
    var maybeMenu = admin_left.find("[href-list=\"" + pathName + "\"]:last");
    if (maybeMenu.length == 0) maybeMenu = admin_left.find("[href-list=\"/channel/list.aspx\"]:last");
    if (maybeMenu.length > 0) {
        admin_left.find("[href-list]").removeClass("left_menu_ison");
        maybeMenu.addClass("left_menu_ison");
        //
        var thisMenu = maybeMenu.parents(".left_menu");
        var nowIsOpenMenu = $(".left_menu_title_kaiguan_open").parents(".left_menu");
        if (nowIsOpenMenu && thisMenu.find(".left_menu_title").attr("href-list") != nowIsOpenMenu.find(".left_menu_title").attr("href-list")) {
            nowIsOpenMenu.find(".left_menu_title_kaiguan").fastClick();
        }
        var menu_ = maybeMenu.parents(".left_menu");
        menu_.find(".left_menu_title_kaiguan").addClass("left_menu_title_kaiguan_open");
        //menu_.find("ul").show();
        menu_.find("ul").animate({ opacity: 1 }).slideDown();
    }
    close_adminRight();
}
function showMenu(locationHref, callBak) {
    // alert("d")
    var maybeMenu = $("[data-AbsoluteUrl*='" + locationHref + "']");
    if (maybeMenu.length > 0) {
        admin_left.find("[href-list]").removeClass("left_menu_ison");
        maybeMenu.addClass("left_menu_ison");
        //
        var thisMenu = maybeMenu.parents(".left_menu");
        var nowIsOpenMenu = $(".left_menu_title_kaiguan_open").parents(".left_menu");
        if (nowIsOpenMenu && thisMenu.find(".left_menu_title").attr("href-list") != nowIsOpenMenu.find(".left_menu_title").attr("href-list")) {
            nowIsOpenMenu.find(".left_menu_title_kaiguan").fastClick();
        }
        var menu_ = maybeMenu.parents(".left_menu");
        menu_.find(".left_menu_title_kaiguan").addClass("left_menu_title_kaiguan_open");
        //menu_.find("ul").show();
        menu_.find("ul").stop().animate({ opacity: 1 }).slideDown(function () {
            callBak();
        });
    }
    close_adminRight();
}


function popover_close() {
    popover.hide();
    frame_popover.attr("src", "").width(100).height(100).hide();

    fenghuolun_close($("#frame_popover_Box"));
}
function open_popover(w, src_, title_, showLeft_) {
    popover.css({ width: "auto", height: "auto", left: "auto", right: "auto" }).removeAttr("data-left").removeAttr("data-right").css({ width: "auto", height: "auto" });
    $("#frame_popover_Box").css({ height: "auto" });

    frame_popover.attr("src", "").width(100).height(100).hide();
    popover.find(".popover-title").html(title_);

    popover.show();
    frame_popover.attr("src", src_);
    if (showLeft_) popover.removeClass("right").addClass("left").attr("data-right", frame_right.width() - w.offset().left * 1 + 10).attr("data-top", w.offset().top * 1 + w.height() / 2 + frame_right.offset().top * 1);
    else popover.removeClass("left").addClass("right").attr("data-left", w.width() * 1 + w.offset().left * 1 + admin_list.offset().left + 1).attr("data-top", w.offset().top * 1 + w.height() / 2);

    resize_popover();

}
function frame_popover_ok() {
    var frameW = frame_popover.contents().outerWidth(true) * 1;
    frame_popover.show().width(frameW);

    var frameH = frame_popover.contents().outerHeight(true) * 1;
    if (frame_popover.contents().outerHeight(true) > frameH) frameW += scrollSize;
    frame_popover.width(frameW).height(frameH);

    resize_popover();
    fenghuolun_close($("#frame_popover_Box"));
}
function resize_popover() {
    ////最右
    //if (accAdd(popover.offset().left, popover.outerWidth(true)) > $(window).width()) {
    //    //popover.width($(window).width() - popover.offset().left);//缩宽度
    //    var posintion2 = $(window).width() - popover.outerWidth(true);//挪位置
    //    if (popover.is("[data-left]")) popover.attr("data-left", posintion2);
    //    else popover.attr("data-right", posintion2);
    //}

    popover.css({ height: "auto" });
    var popoverH = popover.outerHeight(true);
    if (popoverH > admin_list.height()) {//最下
        popoverH = admin_list.height();
        var popover_OtherH = popover.outerHeight(true) - $("#frame_popover_Box").height();
        $("#frame_popover_Box").height(popoverH - popover_OtherH);
        popover.width(accAdd(popover.width(), scrollSize));
    }
    //else popover.width(frame_popover.width());


    if (
        (popover.is("[data-left]") && accAdd(popover.offset().left, popover.outerWidth(true)) > $(window).width()) ||
        (popover.is("[data-right]") && accAdd(popover.attr("data-right"), popover.outerWidth(true)) > $(window).width())
        ) {
        var posintion2 = $(window).width() - popover.outerWidth(true);//挪位置
        if (popover.is("[data-left]")) popover.attr("data-left", posintion2);
        else popover.attr("data-right", posintion2);
    }


    var _top = popover.attr("data-top") - popoverH / 2;
    if (_top < 0) _top = 0;
    else if (accAdd(_top, popoverH) >= admin_list.height()) _top = admin_list.height() - popoverH;

    popover.css({ top: _top });
    if (popover.is("[data-left]")) popover.css({ left: popover.attr("data-left") * 1 });
    else popover.css({ left: "auto", right: popover.attr("data-right") * 1 });
    //
    var arrow = popover.find(".arrow");
    arrow.css({ top: popover.attr("data-top") - _top - arrow.height() / 2 });
    fenghuolun_open_($("#frame_popover_Box"), 1, true, "fff");
    //fenghuolun_close(frame_popover);
}

function MakeOrders_OK(goodsID_) {
    var $thisGoodsElement = $(".ListBox.ing iframe").contents().find("[datakey=" + goodsID_ + "]");
    var flyBox = $("<div class=\"flyBox text-success\"><i class=\"fa fa-check\" ></i></div>")
        .css({
            border: "1px solid #e5e5e5", backgroundColor: "#e5e5e5",
            fontSize: $thisGoodsElement.width(), lineHeight: $thisGoodsElement.height() + "px",
            width: $thisGoodsElement.width(), height: $thisGoodsElement.height(),
            left: accAdd(admin_list.offset().left, $thisGoodsElement.offset().left) - 1, top: accAdd(admin_list.offset().top, $thisGoodsElement.offset().top) - 1
        }).appendTo("body")
    .hide().fadeIn("slow", function () {
        var shoppingCartOffset = $(".fa-shopping-cart").offset();
        flyBox.animate({ top: shoppingCartOffset.top, left: shoppingCartOffset.left, width: 0, height: 0, fontSize: 0, lineHeight: "0px" }, 1000, function () {
            flyBox.remove();
        });
    })
    ;
    Timer1_Update();
}